package com.zh.work.controller.platform.channel;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zh.common.entity.AreaInterceptLog;
import com.zh.common.entity.IpInterceptLog;
import com.zh.common.entity.JSONResult;
import com.zh.common.entity.TransIntercept;
import com.zh.work.entity.StatisticalEntity;
import com.zh.work.service.platform.channel.AreaInterceptLogService;
import com.zh.work.service.platform.channel.IpInterceptLogService;
import com.zh.work.service.platform.channel.RiskTransInterceptLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * code is far away from bug with the animal protecting
 * ┏┓　　　┏┓
 * ┏┛┻━━━┛┻┓
 * ┃　　　　　　　┃
 * ┃　　　━　　　┃
 * ┃　┳┛　┗┳　┃
 * ┃　　　　　　　┃
 * ┃　　　┻　　　┃
 * ┃　　　　　　　┃
 * ┗━┓　　　┏━┛
 * 　　┃　　　┃神兽保佑
 * 　　┃　　　┃代码无BUG！
 * 　　┃　　　┗━━━┓
 * 　　┃　　　　　　　┣┓
 * 　　┃　　　　　　　┏┛
 * 　　┗┓┓┏━┳┓┏┛
 * 　　　┃┫┫　┃┫┫
 * 　　　┗┻┛　┗┻┛
 *
 * @version 1.0
 * @Description : 风控交易日志管理
 * @Author : chenfei
 * @Create in : 2020/10/17 15:17
 */
@Api(value = "交易风控日志控制器", produces = "application/json", tags =  {"交易风控日志控制器"})
@RestController
@RequestMapping("/riskTransInterceptLog")
public class RiskTransInterceptLogController {

    @Autowired
    private  RiskTransInterceptLogService riskTransInterceptLogService;

    @Autowired
    private IpInterceptLogService ipInterceptLogService;

    @Autowired
    private AreaInterceptLogService areaInterceptLogService;

    @ApiOperation(value = "分页查询交易风控日志记录" , tags = {"getPageRiskLog"} , notes = "分页查询交易风控日志记录")
    @GetMapping("/getPageRiskLog")
    public JSONResult<List<TransIntercept>> getPageRiskLog(
            @ApiParam(value = "起始页", name = "pageNo") Integer pageNo,
            @ApiParam(value = "当前页显示数量", name ="pageSize") Integer pageSize,
            @ApiParam(value = "开始时间", name = "addStartTime") String addStartTime,
            @ApiParam(value = "结束时间", name ="addEndTime") String addEndTime,
            @ApiParam(value = "风控日志实体信息", name = "transIntercept") TransIntercept transIntercept){
        JSONResult<List<TransIntercept>> jsonResult = new  JSONResult<>();
        try {
            jsonResult = riskTransInterceptLogService.selectRiskTransLogPage(new Page<>(pageNo, pageSize),addStartTime,addEndTime,transIntercept);
            jsonResult.setMessage("操作成功");
            jsonResult.setSuccess(true);
            jsonResult.setCode(200);
        }catch (Exception e){
            jsonResult.setMessage(e.getMessage());
            jsonResult.setSuccess(false);
            e.printStackTrace();
        }
        return  jsonResult;
    }

    @ApiOperation(value = "分页查询ip黑名单与敏感地区检测日志" , tags = {"getPageIpInterceptLog"} , notes = "分页查询ip黑名单与敏感地区检测日志")
    @GetMapping("/getPageIpInterceptLog")
    public JSONResult<List<IpInterceptLog>> getPageIpInterceptLog(
            @ApiParam(value = "起始页", name = "pageNo") Integer pageNo,
            @ApiParam(value = "当前页显示数量", name ="pageSize") Integer pageSize,
            @ApiParam(value = "开始时间", name = "addStartTime") String addStartTime,
            @ApiParam(value = "结束时间", name ="addEndTime") String addEndTime,
            @ApiParam(value = "ip黑名单与敏感地区检测日志实体信息", name = "ipInterceptLog") IpInterceptLog ipInterceptLog){
        JSONResult<List<IpInterceptLog>> jsonResult = new  JSONResult<>();
        try {
            jsonResult = ipInterceptLogService.getPageIpInterceptLog(new Page<>(pageNo, pageSize),addStartTime,addEndTime,ipInterceptLog);
            jsonResult.setMessage("操作成功");
            jsonResult.setSuccess(true);
            jsonResult.setCode(200);
        }catch (Exception e){
            jsonResult.setMessage(e.getMessage());
            jsonResult.setSuccess(false);
            e.printStackTrace();
        }
        return  jsonResult;
    }

    @ApiOperation(value = "分页查询限制地区检测日志" , tags = {"getPageAreaInterceptLog"}  , notes = "分页查询限制地区检测日志")
    @GetMapping("/getPageAreaInterceptLog")
    public JSONResult<List<AreaInterceptLog>> getPageAreaInterceptLog(
            @ApiParam(value = "起始页", name = "pageNo") Integer pageNo,
            @ApiParam(value = "当前页显示数量", name ="pageSize") Integer pageSize,
            @ApiParam(value = "开始时间", name = "addStartTime") String addStartTime,
            @ApiParam(value = "结束时间", name ="addEndTime") String addEndTime,
            @ApiParam(value = "限制地区检测日志实体信息", name = "ipInterceptLog") AreaInterceptLog areaInterceptLog){
        JSONResult<List<AreaInterceptLog>> jsonResult = new  JSONResult<>();
        try {
            jsonResult = areaInterceptLogService.getPageAreaInterceptLog(new Page<>(pageNo, pageSize),addStartTime,addEndTime,areaInterceptLog);
            jsonResult.setMessage("操作成功");
            jsonResult.setSuccess(true);
            jsonResult.setCode(200);
        }catch (Exception e){
            jsonResult.setMessage(e.getMessage());
            jsonResult.setSuccess(false);
            e.printStackTrace();
        }
        return  jsonResult;
    }

    @ApiOperation(value = "统计风控交易日志记录" , tags = {"getStatisticsRiskTransLog"}  , notes = "统计风控交易日志记录")
    @GetMapping("/getStatisticsRiskTransLog")
    public JSONResult<List<StatisticalEntity>> getStatisticsRiskTransLog(){
        JSONResult<List<StatisticalEntity>> jsonResult = new  JSONResult<>();
        try {
            jsonResult.setData( riskTransInterceptLogService.selectStatisticsRiskTransLog());
            jsonResult.setMessage("操作成功");
            jsonResult.setSuccess(true);
            jsonResult.setCode(200);
        }catch (Exception e){
            jsonResult.setMessage(e.getMessage());
            jsonResult.setSuccess(false);
            e.printStackTrace();
        }
        return  jsonResult;
    }

    @ApiOperation(value = "统计ip黑名单与敏感地区检测日志" ,  tags = {"getStatisticsIpInterceptLog"} , notes = "统计ip黑名单与敏感地区检测日志")
    @GetMapping("/getStatisticsIpInterceptLog")
    public JSONResult<List<StatisticalEntity>> getStatisticsIpInterceptLog(){
        JSONResult<List<StatisticalEntity>> jsonResult = new  JSONResult<>();
        try {
            jsonResult.setData( ipInterceptLogService.selectStatisticsRiskTransLog());
            jsonResult.setMessage("操作成功");
            jsonResult.setSuccess(true);
            jsonResult.setCode(200);
        }catch (Exception e){
            jsonResult.setMessage(e.getMessage());
            jsonResult.setSuccess(false);
            e.printStackTrace();
        }
        return  jsonResult;
    }

    @ApiOperation(value = "统计限制地区检测日志" , tags = {"getStatisticsAreaInterceptLog"} , notes = "统计限制地区检测日志")
    @GetMapping("/getStatisticsAreaInterceptLog")
    public JSONResult<List<StatisticalEntity>> getStatisticsAreaInterceptLog(){
        JSONResult<List<StatisticalEntity>> jsonResult = new  JSONResult<>();
        try {
            jsonResult.setData(areaInterceptLogService.selectStatisticsAreaInterceptLog());
            jsonResult.setMessage("操作成功");
            jsonResult.setSuccess(true);
            jsonResult.setCode(200);
        }catch (Exception e){
            jsonResult.setMessage(e.getMessage());
            jsonResult.setSuccess(false);
            e.printStackTrace();
        }
        return  jsonResult;
    }




}
